package Mystack;

import java.util.Arrays;
import java.util.Stack;

public class Mystack {
    public int[] elem;
    public int size;

    public Mystack() {
        elem = new int[10];
    }

    public void push(int date) {
        if (ifFull()) {
            elem = Arrays.copyOf(elem, elem.length * 2);
        }
        elem[size] = date;
        size++;
    }

    public boolean ifFull() {
        return size == elem.length;
    }

    public void show(){
        for (int i = 0; i < size; i++) {
            System.out.print(elem[i]+" ");
        }
        System.out.println();
    }

    public int pop(){
        if (isEmpy()){
            return -1;
        }
        int oldval = elem[size-1];
        size--;
        return oldval;
    }

    public boolean isEmpy(){
        return size==0;
    }
    public int peek(){
        if (isEmpy()){
            return -1;
        }
        int oldval = elem[size-1];
        return oldval;
    }

    /*public void pop(){
        System.out.println(elem[--size]);
    }*/

    public void size(){
        System.out.println(size);
    }


}
